package com.phc.a20200511work.paopao;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.phc.a20200511work.R;

import java.util.List;

public class paopao extends AppCompatActivity {


    private ListView activityPaopaoListview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_paopao);
        initView();
        //拿到数据
        pappaoData data = new pappaoData();
        List<String> dailyKindList = data.dailyKindList;
        String[] dataArray = (String[]) dailyKindList.toArray();
        //进行适配
        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this
                , android.R.layout.simple_list_item_1, android.R.id.text1, dataArray);
        activityPaopaoListview.setAdapter(arrayAdapter);
        //listview点击事件
        activityPaopaoListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(paopao.this,paopaoGoods.class);
                //带选择的位置传递出去
                intent.putExtra("type",position);
                startActivity(intent);
            }
        });
    }

    private void initView() {

        activityPaopaoListview = (ListView) findViewById(R.id.activity_paopao_listview);
    }
}
